package model;

/**
 * 
 * @author Sonny Sandberg
 */
public class Product
{
    private int id;
    private String 
            name,
            size;
    private double
            purchasePrice,
            salesPrice;
    private boolean
            hasDecoration,
            remainAfterSale,
            active,
            sold;
    private ProductFamily productFamily;

    public Product(int id, String name, String size, double purchasePrice, double salesPrice, boolean hasDecoration, boolean remainAfterSale, boolean active, boolean sold, ProductFamily productFamily)
    {
        this.id = id;
        this.name = name;
        this.size = size;
        this.purchasePrice = purchasePrice;
        this.salesPrice = salesPrice;
        this.hasDecoration = hasDecoration;
        this.remainAfterSale = remainAfterSale;
        this.active = active;
        this.sold = sold;
        this.productFamily = productFamily;
    }

    public Product()
    {
        this.id = 0;
        this.name = "";
        this.size = "";
        this.purchasePrice = 0;
        this.salesPrice = 0;
        this.hasDecoration = false;
        this.remainAfterSale = false;
        this.active = true;
        this.sold = false;
        this.productFamily = new ProductFamily();
    }
    
    public void resetObjectValues()
    {
        this.id = 0;
        this.name = "";
        this.size = "";
        this.purchasePrice = 0;
        this.salesPrice = 0;
        this.hasDecoration = false;
        this.remainAfterSale = false;
        this.active = true;
        this.sold = false;
        this.productFamily = null;
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getSize()
    {
        return size;
    }

    public void setSize(String size)
    {
        this.size = size;
    }

    public double getPurchasePrice()
    {
        return purchasePrice;
    }

    public void setPurchasePrice(double purchasePrice)
    {
        this.purchasePrice = purchasePrice;
    }

    public double getSalesPrice()
    {
        return salesPrice;
    }

    public void setSalesPrice(double salesPrice)
    {
        this.salesPrice = salesPrice;
    }

    public boolean isHasDecoration()
    {
        return hasDecoration;
    }

    public void setHasDecoration(boolean hasDecoration)
    {
        this.hasDecoration = hasDecoration;
    }

    public boolean isRemainAfterSale()
    {
        return remainAfterSale;
    }

    public void setRemainAfterSale(boolean remainAfterSale)
    {
        this.remainAfterSale = remainAfterSale;
    }

    public boolean isActive()
    {
        return active;
    }

    public void setActive(boolean active)
    {
        this.active = active;
    }

    public boolean isSold()
    {
        return sold;
    }

    public void setSold(boolean sold)
    {
        this.sold = sold;
    }

    public ProductFamily getProductFamily()
    {
        return productFamily;
    }

    public void setProductFamily(ProductFamily productFamily)
    {
        this.productFamily = productFamily;
    }
    
    public boolean isCompleted()
    {
        boolean answer = false;
        
        if (name.length() > 0 && productFamily != null)
        {
            answer = true;
        }
        
        return answer;
    }
    
    @Override
    public String toString()
    {
        String text = "";
        
        text = String.format("ID: %d\nNavn: %s\nStørrelse: %s\nKøbspris: %s\nSalgspris: %s\nHar Dekoration: %b\nServiceprodukt: %b\nAktiv: %b\nSolgt: %b\nVaregruppe: %s", 
                id, name, size, purchasePrice, salesPrice, hasDecoration, remainAfterSale, active, sold, productFamily.toString());
        
        return text;
    }
    
}
